home *** CD-ROM | disk | FTP | other *** search
/ ASME's Mechanical Engine…ing Toolkit 1997 December / ASME's Mechanical Engineering Toolkit 1997 December.iso / basic / bwtool.lzh / NEWSCRN.ASM < prev    next >
Assembly Source File  |  1986-11-30  |  5KB  |  103 lines

  1. bios_data     segment   at 40h
  2.               org       10h
  3. equip_flag    label     word
  4.               org       63h
  5. addr_6845     label     word
  6. bios_data     ends
  7.  
  8. code          segment   byte public 'CODE'
  9.               assume    cs:code,ds:code
  10.               public    savescrn, restscrn
  11.  
  12. savescrn      proc      far
  13.               push      bp                       ;save for BASIC
  14.               mov       bp,sp                    ;set up Base Pointer
  15.               push      es                       ;save for BASIC
  16.               mov       bx,6[bp]                 ;get location of array
  17.               mov       si,[bx]                  ;
  18.               call      get_set                  ;set up transfer conditions
  19.               push      es                       ;exchange ES and DS registers
  20.               push      ds                       ;since we are moving data
  21.               pop       es                       ;from screen to array
  22.               pop       ds                       ;
  23.               xchg      si,di                    ;exchange indexes too
  24.               call      go                       ;do transfer
  25.               push      es                       ;restore ES and DS to proper
  26.               push      ds                       ;values.
  27.               pop       es                       ;
  28.               pop       ds                       ;
  29.  
  30.               pop       es                       ;prepare to return to BASIC
  31.               pop       bp                       ;
  32.               ret       4                        ;go past 2 parameters
  33. savescrn      endp
  34.  
  35. restscrn      proc      far
  36.               push      bp                       ;save for BASIC
  37.               mov       bp,sp                    ;set up Base Pointer
  38.               push      es                       ;save for BASIC
  39.               mov       bx,6[bp]                 ;get location of array
  40.               mov       si,[bx]                  ;
  41.               call      get_set                  ;set up transfer conditions
  42.               call      go                       ;do transfer
  43.               pop       es                       ;prepare to return to BASIC
  44.               pop       bp                       ;
  45.               ret       4                        ;go past 2 parameters
  46. restscrn      endp
  47.  
  48. get_set       proc      near
  49.               xor       di,di                    ;
  50.               mov       cx,2000                  ;number of transfers to do
  51.               mov       bx,bios_data             ;
  52.               mov       es,bx                    ;point to BIOS data block
  53.               mov       dx,es:addr_6845          ;set up DX to base of 6845
  54.               add       dx,6                     ;set it up for status port
  55.               mov       ax,0B800H                ;assume it is a color card
  56.               mov       bx,es:equip_flag         ;test to see if it is
  57.               and       bx,30h                   ;
  58.               cmp       bx,30h                   ;
  59.               jne       ok                       ;ok it is color
  60.               mov       ax,0B000H                ;no, it's monochrome
  61. ok:           mov       es,ax                    ;set up address in ES
  62.               ret
  63. get_set       endp
  64.  
  65. go            proc      near
  66.  
  67.               mov       ax,8[bp]                 ;get snowtest parameter
  68.               cmp       ax,1                     ;is it ok for no snow?
  69.               jz        notest                   ;yes, do fast transfer
  70.  
  71. testcard:     mov       bx,es                    ;test destination
  72.               cmp       bx,0B000H                ;is it monochrome?
  73.               jz        notest                   ;yes, do fast transfer
  74. again:        mov       bx,ds                    ;test source
  75.               cmp       bx,0B000H                ;same here except for screen
  76.               jz        notest                   ;restore
  77.  
  78.                                                  ;if all above tests fail,
  79.                                                  ;card must be an IBM CGA
  80.                                                  ;and must test for snow
  81.  
  82.  
  83. ibmcga:       cli                                ;disable interrupts
  84. test_lo:      in        al,dx                    ;test horizontal retrace
  85.               shr       al,1                     ;wait 'til it's low
  86.               jc        test_lo                  ;
  87. test_hi:      in        al,dx                    ;now test 'til it's high
  88.               shr       al,1                     ;
  89.               jnc       test_hi                  ;
  90.               movsw                              ;ok now to move char and attr
  91.               loop      test_lo                  ;do 2000 times for full screen
  92.               sti                                ;restore interrupts
  93.               ret
  94.  
  95. notest:       movsw                              ;move character and attribute
  96.               loop      notest                   ;do 2000 times
  97.               ret
  98.  
  99. go            endp
  100.  
  101. code          ends
  102.               end
  103.